define(["angular"], function(angular) {
	var orgContext = "/grm/ecp/RemoteServiceServlet?callName=com.ygsoft.community.service.context.IOrgContext.";
	
	var requestHeader = {
		headers : {
			"Content-Type" : "application/x-www-form-urlencoded; charset=UTF-8"
		}
	};
	
	return {
		"OrgService" : ["$http", function($http) {
			return {
				// 服务：获取组织树
				getOrgTree: function () {
					return $http.get(orgContext + "getOrgList()");
				},
				
				// 服务：保存组织
				saveOrg: function (org) {
					return $http.post(orgContext + "saveOrg(org)", $.param({
						org:angular.toJson(org)
					}),requestHeader);
				},
				
				// 服务：更新组织
				update : function (org) {
					return $http.post(orgContext + "updateOrg(org)", $.param({
						org:angular.toJson(org)
					}),requestHeader);
				},

				// 服务：删除组织
				deleteOrg: function (orgId) {
					return $http.post(orgContext + "deleteOrg(orgId)", $.param({
						orgId:orgId
					}),requestHeader);
				},
				
				// 服务：根据组织id获取组织
				getOrgById: function(orgId) {
					return $http.post(orgContext + "getOrgById(orgId)", $.param({
						orgId : orgId
					}), requestHeader);
				},
				
				//服务：根据组织id获取组织列表
				getOrgListByIds : function (orgIds) {
					return $http.post(orgContext + "getOrgListByIds(orgIds)", $.param({
						orgIds : angular.toJson(orgIds)
					}), requestHeader);
				},
			}
				
		}]
	};
});
